﻿Imports System.Collections.Generic
Public Class CChiTietPhieuDAO
    'phuong thuc lay danh sach dua vao ma mon
  
    Public Shared Function laydanhsachchitiet(ByVal maban As String) As List(Of CChiTietPhieu)
        Dim kq As List(Of CChiTietPhieu) = New List(Of CChiTietPhieu)
        Dim str As String = String.Format("SELECT * from ChiTietPhieu where MaBan={0} ", maban)
        Dim dt As DataTable = CKetNoi.ExecQuery(str)
        For Each i As DataRow In dt.Rows
            Dim chitiet As New CChiTietPhieu
            chitiet.maphieu = i("MaPhieu")
            chitiet.mamon = i("MaMon")
            chitiet.maban = i("MaBan")
            chitiet.soluong = i("SoLuong")
            chitiet.machitietphieu = i("MaChiTietPhieu")
            chitiet.dongia = i("DonGia")
            kq.Add(chitiet)
        Next
        Return kq
    End Function
    Public Shared Function Insert(ByVal b As CChiTietPhieu) As Integer
        Dim sql As String = String.Format("INSERT INTO ChiTietPhieu(MaPhieu,MaMon,DonGia,MaBan,SoLuong) VALUES({0},{1},{2},{3},{4})", b.maphieu, b.mamon, b.dongia, b.maban, b.soluong)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
    Public Shared Function Delete(ByVal maphieu As String) As Integer
        Dim sql As String = String.Format("Delete from ChiTietPhieu where MaPhieu='{0}'", maphieu)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
  
End Class
